<template>
  <el-form ref="form" :model="form" label-width="80px">
    <el-form-item label="分类名称">
      <el-input v-model="form.name" />
    </el-form-item>
    <el-form-item label="分类编码">
      <el-input v-model="form.code" />
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit(form)">立即创建</el-button>
      <el-button>取消</el-button>
    </el-form-item>
  </el-form>
</template>

<script>

import { addClass } from '@/api/class'

export default {
  name: 'Index',
  data() {
    return {
      form: {
        name: '',
        code: ''
      }
    }
  },
  methods: {
    onSubmit(data) {
      console.log('submit!')
      addClass(data).then(res => {
        console.log(res)
        if (res.code === 100) {
          alert('成功')
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
